<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function add_drawing_mention($object_id, $mention_id) {
    if(!$object_id || !$mention_id)
        return FALSE;
    $time = time();
    $query = "INSERT INTO drawing_mentions (object_id, mention_id, timestamp) 
                            VALUES('$object_id', '$mention_id', '$time')";
    return safe_insert_query($query);
}

function add_drawing_mentions($object_id, $mention_ids) {
    if(!$object_id || !is_array($mention_ids) || !$mention_ids[0])
        return FALSE;
    $time = time();
    $mention_id = $mention_ids[0];
    $query = "INSERT INTO drawing_mentions (object_id, mention_id, timestamp) 
                            VALUES('$object_id', '$mention_id', '$time')";
    for($index = 1; $index < count($mention_ids); $index++) {
        $mention_id = $mention_ids[$index];
        $query .= ",('$object_id', '$mention_id', '$time')";
    }
    return safe_insert_query($query);
}

function get_drawing_mention_id($object_id) {
    $query = "SELECT tag FROM drawing_mentions WHERE object_id = '$object_id' LIMIT 0, 1";
    $result = safe_select_query($query);
    return $result[0];
}

function get_drawing_mention_ids($object_id) {
    $query = "SELECT mention_id FROM drawing_mentions WHERE object_id = '$object_id'";
    $result = safe_select_query($query);
    return $result;
}

?>
